package com.ctshk.sapp.airexpress.convertor;

import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.ctshk.common.utils.EntityUtil;
import com.ctshk.common.utils.individual.conversion.*;
import com.ctshk.common.utils.individual.scenic.*;
import com.ctshk.common.utils.individual.scenic.ChannelSaleReq;
import com.ctshk.common.utils.individual.scenic.dto.*;
import com.ctshk.common.utils.individual.scenic.req.*;
import com.ctshk.rpc.airexpress.dto.*;
import com.ctshk.rpc.airexpress.req.*;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 *
 * </p>
 *
 * @author 胡广
 * @since 2021/3/16
 */
public class Convertor {
    /**
     * 门票结构转成机场快线结构，l2 to l1
     *
     * @param scenicProductBatchSaleStrategyReq
     * @return
     */
    /*public static AirportExpressIncreaseStrategySaveBatchReq scenicToAirportExpress(ScenicProductBatchSaleStrategyReq scenicProductBatchSaleStrategyReq) {
        AirportExpressIncreaseStrategySaveBatchReq airportExpressIncreaseStrategySaveBatchReq = new AirportExpressIncreaseStrategySaveBatchReq();
        // 获取机场快线ID列表
        airportExpressIncreaseStrategySaveBatchReq.setAirportExpressIdList(scenicProductBatchSaleStrategyReq.getScenicProductIdList());
        // 获取策略列表
        List<ScenicProductSaleStrategyReq> scenicProductSaleStrategyReqList = scenicProductBatchSaleStrategyReq.getStrategyList();
        List<AirportExpressIncreaseStrategyReq> airportExpressIncreaseStrategyReqList = new ArrayList<>();
        airportExpressIncreaseStrategySaveBatchReq.setAirportExpressIncreaseStrategyList(airportExpressIncreaseStrategyReqList);
        for (ScenicProductSaleStrategyReq scenicProductSaleStrategyReq : scenicProductSaleStrategyReqList) {
            AirportExpressIncreaseStrategyReq airportExpressIncreaseStrategyReq = new AirportExpressIncreaseStrategyReq();
            airportExpressIncreaseStrategyReqList.add(airportExpressIncreaseStrategyReq);
            //策略主表
            airportExpressIncreaseStrategyReq.setAirportExpressId(scenicProductSaleStrategyReq.getProductId());
            airportExpressIncreaseStrategyReq.setIncreaseStrategyName(scenicProductSaleStrategyReq.getName());

            //策略时间
            List<ScenicTimeDTO> scenicTimeDTOList = scenicProductSaleStrategyReq.getTime();
            List<AirportExpressIncreaseStrategyDateReq> airportExpressIncreaseStrategyDateReqList = new ArrayList<>();
            AirportExpressIncreaseStrategyDateReq airportExpressIncreaseStrategyDateReq = null;
            for (ScenicTimeDTO scenicTimeDTO : scenicTimeDTOList) {
                airportExpressIncreaseStrategyDateReq = new AirportExpressIncreaseStrategyDateReq();
                airportExpressIncreaseStrategyDateReq.setDateBegin(scenicTimeDTO.getBeginTime());
                airportExpressIncreaseStrategyDateReq.setDateEnd(scenicTimeDTO.getEndTime());
                airportExpressIncreaseStrategyDateReqList.add(airportExpressIncreaseStrategyDateReq);
            }
            airportExpressIncreaseStrategyReq.setAirportExpressIncreaseStrategyDateList(airportExpressIncreaseStrategyDateReqList);
            //渠道加幅规则
            ChannelSaleReq channelSaleReq = scenicProductSaleStrategyReq.getChannelSaleReq();
            //渠道加幅规则-线下自营渠道
            ScenicProductOfflineChannelReq scenicProductOfflineChannelReq = channelSaleReq.getScenicProductOfflineChannelReq();
            if (scenicProductOfflineChannelReq != null) {
                airportExpressIncreaseStrategyReq.setSelfSalePermissionType(scenicProductOfflineChannelReq.getVisableType());
                if (airportExpressIncreaseStrategyReq.getSelfSalePermissionType() != null) {
                    if (airportExpressIncreaseStrategyReq.getSelfSalePermissionType() == 2) {
                        AirportExpressIncreaseStrategyRuleReq airportExpressIncreaseStrategySelfRule = EntityUtil.copy(scenicProductOfflineChannelReq, AirportExpressIncreaseStrategyRuleReq.class);
//                        AirportExpressIncreaseStrategyRuleReq airportExpressIncreaseStrategySelfRule = new AirportExpressIncreaseStrategyRuleReq();
                        //是否限购转换（门票景点 0：不限购  1：限购） =》  （业务 1：不限购 2 ：限购）
//                        convertorLimitNum(scenicProductOfflineChannelReq, airportExpressIncreaseStrategySelfRule);
                        airportExpressIncreaseStrategySelfRule.setSaleableType(scenicProductOfflineChannelReq.getIsLimit());
                        airportExpressIncreaseStrategySelfRule.setSaleableNumber(scenicProductOfflineChannelReq.getLimitNum());

                        airportExpressIncreaseStrategyReq.setAirportExpressIncreaseStrategySelfRule(airportExpressIncreaseStrategySelfRule);
                    } else if (airportExpressIncreaseStrategyReq.getSelfSalePermissionType() == 3) {
                        List<AirportExpressChannelOfflineSelfCustomReq> airportExpressChannelOfflineSelfCustomReqList = new ArrayList<>();

                        List<ScenicProductChannelOfflineSelfCustomReq> scenicProductChannelOfflineSelfCustomReqList = scenicProductOfflineChannelReq.getScenicProductChannelOfflineSelfCustomReqList();
                        for (ScenicProductChannelOfflineSelfCustomReq scenicProductChannelOfflineSelfCustomReq : scenicProductChannelOfflineSelfCustomReqList) {
                            AirportExpressChannelOfflineSelfCustomReq airportExpressChannelOfflineSelfCustomReq = new AirportExpressChannelOfflineSelfCustomReq();
                            airportExpressChannelOfflineSelfCustomReq.setName(scenicProductChannelOfflineSelfCustomReq.getName());
                            airportExpressChannelOfflineSelfCustomReq.setCheckType(scenicProductChannelOfflineSelfCustomReq.getCheckType());
                            airportExpressChannelOfflineSelfCustomReq.setRelationId(scenicProductChannelOfflineSelfCustomReq.getRelationId());
                            // rule
                            AirportExpressIncreaseStrategyRuleReq airportExpressIncreaseStrategySelfRule = EntityUtil.copy(scenicProductChannelOfflineSelfCustomReq, AirportExpressIncreaseStrategyRuleReq.class);
//                            AirportExpressIncreaseStrategyRuleReq airportExpressIncreaseStrategySelfRule = new AirportExpressIncreaseStrategyRuleReq();
                            //是否限购转换（门票景点 0：不限购  1：限购） =》  （业务 1：不限购 2 ：限购）
                            //convertorLimitNum(scenicProductChannelOfflineSelfCustomReq, airportExpressIncreaseStrategySelfRule);
                            airportExpressIncreaseStrategySelfRule.setSaleableType(scenicProductChannelOfflineSelfCustomReq.getIsLimit());
                            airportExpressIncreaseStrategySelfRule.setSaleableNumber(scenicProductChannelOfflineSelfCustomReq.getLimitNum());

                            airportExpressChannelOfflineSelfCustomReq.setAirportExpressIncreaseStrategyRule(airportExpressIncreaseStrategySelfRule);
                            airportExpressChannelOfflineSelfCustomReqList.add(airportExpressChannelOfflineSelfCustomReq);
                        }
                        airportExpressIncreaseStrategyReq.setAirportExpressChannelOfflineSelfCustomList(airportExpressChannelOfflineSelfCustomReqList);
                    }
                }
            }
            //渠道加幅规则-线下代理商渠道
            ScenicProductAgentReq scenicProductAgentReq = channelSaleReq.getScenicProductAgentReq();
            if (scenicProductAgentReq != null) {
                airportExpressIncreaseStrategyReq.setAgentSalePermissionType(scenicProductAgentReq.getVisableType());
                if (airportExpressIncreaseStrategyReq.getAgentSalePermissionType() != null) {
                    if (airportExpressIncreaseStrategyReq.getAgentSalePermissionType() == 2) {
                        AirportExpressIncreaseStrategyRuleReq airportExpressIncreaseStrategySelfRule = EntityUtil.copy(scenicProductAgentReq, AirportExpressIncreaseStrategyRuleReq.class);
//                        AirportExpressIncreaseStrategyRuleReq airportExpressIncreaseStrategySelfRule = new AirportExpressIncreaseStrategyRuleReq();
                        //是否限购转换（门票景点 0：不限购  1：限购） =》  （业务 1：不限购 2 ：限购）
                        //convertorLimitNum(scenicProductAgentReq, airportExpressIncreaseStrategySelfRule);
                        airportExpressIncreaseStrategySelfRule.setSaleableType(scenicProductAgentReq.getIsLimit());
                        airportExpressIncreaseStrategySelfRule.setSaleableNumber(scenicProductAgentReq.getLimitNum());

                        airportExpressIncreaseStrategyReq.setAirportExpressIncreaseStrategyAgentRule(airportExpressIncreaseStrategySelfRule);
                    } else if (airportExpressIncreaseStrategyReq.getAgentSalePermissionType() == 3) {
                        List<AirportExpressChannelOfflineAgentCustomReq> airportExpressChannelOfflineAgentCustomReqs = new ArrayList<>();

                        List<ScenicProductChannelOfflineAgentCustomReq> scenicProductChannelOfflineAgentCustomReqList = scenicProductAgentReq.getScenicProductChannelOfflineAgentCustomReqList();
                        for (ScenicProductChannelOfflineAgentCustomReq scenicProductChannelOfflineAgentCustomReq : scenicProductChannelOfflineAgentCustomReqList) {
                            AirportExpressChannelOfflineAgentCustomReq airportExpressChannelOfflineAgentCustomReq = new AirportExpressChannelOfflineAgentCustomReq();
                            airportExpressChannelOfflineAgentCustomReq.setAgentId(scenicProductChannelOfflineAgentCustomReq.getAgentId());
                            airportExpressChannelOfflineAgentCustomReq.setAgentName(scenicProductChannelOfflineAgentCustomReq.getAgentName());
                            //
                            AirportExpressIncreaseStrategyRuleReq airportExpressIncreaseStrategySelfRule = EntityUtil.copy(scenicProductChannelOfflineAgentCustomReq, AirportExpressIncreaseStrategyRuleReq.class);
//                            AirportExpressIncreaseStrategyRuleReq airportExpressIncreaseStrategySelfRule = new AirportExpressIncreaseStrategyRuleReq();
                            //是否限购转换（门票景点 0：不限购  1：限购） =》  （业务 1：不限购 2 ：限购）
                            //convertorLimitNum(scenicProductChannelOfflineAgentCustomReq, airportExpressIncreaseStrategySelfRule);
                            airportExpressIncreaseStrategySelfRule.setSaleableType(scenicProductChannelOfflineAgentCustomReq.getIsLimit());
                            airportExpressIncreaseStrategySelfRule.setSaleableNumber(scenicProductChannelOfflineAgentCustomReq.getLimitNum());
                            // 数值百分比转换（门票景点  0：加数值  1：百分比） =》（业务 1：加数值 2：百分比）
                            //成人单程

                            airportExpressChannelOfflineAgentCustomReq.setAirportExpressIncreaseStrategyRule(airportExpressIncreaseStrategySelfRule);
                            airportExpressChannelOfflineAgentCustomReqs.add(airportExpressChannelOfflineAgentCustomReq);
                        }
                        airportExpressIncreaseStrategyReq.setAirportExpressChannelOfflineAgentCustomList(airportExpressChannelOfflineAgentCustomReqs);
                    }
                }
            }
            //渠道加幅规则-线上自营渠道官方平台
            List<ScenicProductChannelOnlineSelfPlatformReq> scenicProductChannelOnlineSelfPlatformReqList = channelSaleReq.getScenicProductChannelOnlineSelfPlatformReqList();
            List<AirportExpressChannelOnlineSelfPlatformReq> airportExpressChannelOnlineSelfPlatformReqList = new ArrayList<>();
            airportExpressIncreaseStrategyReq.setAirportExpressChannelOnlineSelfPlatformList(airportExpressChannelOnlineSelfPlatformReqList);
            if (CollectionUtils.isNotEmpty(scenicProductChannelOnlineSelfPlatformReqList)) {
                for (ScenicProductChannelOnlineSelfPlatformReq scenicProductChannelOnlineSelfPlatformReq : scenicProductChannelOnlineSelfPlatformReqList) {
                    AirportExpressChannelOnlineSelfPlatformReq airportExpressChannelOnlineSelfPlatformReq = new AirportExpressChannelOnlineSelfPlatformReq();
                    //渠道信息
                    airportExpressChannelOnlineSelfPlatformReq.setChannelId(scenicProductChannelOnlineSelfPlatformReq.getChannelId());
                    airportExpressChannelOnlineSelfPlatformReq.setChannelName(scenicProductChannelOnlineSelfPlatformReq.getChannelName());
                    //
                    AirportExpressIncreaseStrategyRuleReq airportExpressIncreaseStrategyRule = EntityUtil.copy(scenicProductChannelOnlineSelfPlatformReq, AirportExpressIncreaseStrategyRuleReq.class);
//                    AirportExpressIncreaseStrategyRuleReq airportExpressIncreaseStrategyRule = new AirportExpressIncreaseStrategyRuleReq();
                    //是否限购转换（门票景点 0：不限购  1：限购） =》  （业务 1：不限购 2 ：限购）
                    //convertorLimitNum(scenicProductChannelOnlineSelfPlatformReq, airportExpressIncreaseStrategyRule);
                    airportExpressIncreaseStrategyRule.setSaleableType(scenicProductChannelOnlineSelfPlatformReq.getIsLimit());
                    airportExpressIncreaseStrategyRule.setSaleableNumber(scenicProductChannelOnlineSelfPlatformReq.getLimitNum());
                    // 数值百分比转换（门票景点  0：加数值  1：百分比） =》（业务 1：加数值 2：百分比）
                    //成人单程加幅价格

                    airportExpressChannelOnlineSelfPlatformReq.setAirportExpressIncreaseStrategyRule(airportExpressIncreaseStrategyRule);
                    airportExpressChannelOnlineSelfPlatformReqList.add(airportExpressChannelOnlineSelfPlatformReq);
                }
            }
            //渠道加幅规则-线上第三方平台
            List<ScenicProductChannelOnlineThirdPlatformReq> scenicProductChannelOnlineThirdPlatformReqList = channelSaleReq.getScenicProductChannelOnlineThirdPlatformReqList();
            List<AirportExpressChannelOnlineThirdPlatformReq> airportExpressChannelOnlineThirdPlatformList = new ArrayList<>();
            airportExpressIncreaseStrategyReq.setAirportExpressChannelOnlineThirdPlatformList(airportExpressChannelOnlineThirdPlatformList);
            if (CollectionUtils.isNotEmpty(scenicProductChannelOnlineThirdPlatformReqList)) {
                for (ScenicProductChannelOnlineThirdPlatformReq scenicProductChannelOnlineThirdPlatformReq : scenicProductChannelOnlineThirdPlatformReqList) {
                    AirportExpressChannelOnlineThirdPlatformReq airportExpressChannelOnlineThirdPlatformReq = new AirportExpressChannelOnlineThirdPlatformReq();
                    //渠道信息
                    airportExpressChannelOnlineThirdPlatformReq.setPlatformId(scenicProductChannelOnlineThirdPlatformReq.getPlatformId());
                    airportExpressChannelOnlineThirdPlatformReq.setPlatformName(scenicProductChannelOnlineThirdPlatformReq.getPlatformName());
                    //
                    AirportExpressIncreaseStrategyRuleReq airportExpressIncreaseStrategyRule = EntityUtil.copy(scenicProductChannelOnlineThirdPlatformReq, AirportExpressIncreaseStrategyRuleReq.class);
//                    AirportExpressIncreaseStrategyRuleReq airportExpressIncreaseStrategyRule = new AirportExpressIncreaseStrategyRuleReq();
                    //是否限购转换（门票景点 0：不限购  1：限购） =》  （业务 1：不限购 2 ：限购）
                    //convertorLimitNum(scenicProductChannelOnlineThirdPlatformReq, airportExpressIncreaseStrategyRule);
                    airportExpressIncreaseStrategyRule.setSaleableType(scenicProductChannelOnlineThirdPlatformReq.getIsLimit());
                    airportExpressIncreaseStrategyRule.setSaleableNumber(scenicProductChannelOnlineThirdPlatformReq.getLimitNum());
                    // 数值百分比转换（门票景点  0：加数值  1：百分比） =》（业务 1：加数值 2：百分比）
                    //成人单程加幅价格

                    airportExpressChannelOnlineThirdPlatformReq.setAirportExpressIncreaseStrategyRule(airportExpressIncreaseStrategyRule);
                    airportExpressChannelOnlineThirdPlatformList.add(airportExpressChannelOnlineThirdPlatformReq);
                }
            }
        }
        return airportExpressIncreaseStrategySaveBatchReq;
    }*/

    public static AirportExpressIncreaseStrategySaveBatchReq scenicToAirportExpress(ProductIncreaseStrategyBatchReq productIncreaseStrategyBatchReq) {
        AirportExpressIncreaseStrategySaveBatchReq airportExpressIncreaseStrategySaveBatchReq = new AirportExpressIncreaseStrategySaveBatchReq();
        // 获取机场快线ID列表
        airportExpressIncreaseStrategySaveBatchReq.setAirportExpressIdList(productIncreaseStrategyBatchReq.getProductIdList());
        // 获取策略列表
        List<ProductIncreaseStrategyReq> productSaleStrategyReqList = productIncreaseStrategyBatchReq.getStrategyList();
        List<AirportExpressIncreaseStrategyReq> airportExpressIncreaseStrategyReqList = new ArrayList<>();
        airportExpressIncreaseStrategySaveBatchReq.setAirportExpressIncreaseStrategyList(airportExpressIncreaseStrategyReqList);
        for (Long productId : productIncreaseStrategyBatchReq.getProductIdList()) {
            for (ProductIncreaseStrategyReq productIncreaseStrategyReq : productSaleStrategyReqList) {
                AirportExpressIncreaseStrategyReq airportExpressIncreaseStrategyReq = new AirportExpressIncreaseStrategyReq();
                airportExpressIncreaseStrategyReqList.add(airportExpressIncreaseStrategyReq);
                //策略主表
                airportExpressIncreaseStrategyReq.setId(productIncreaseStrategyReq.getIncreaseStrategyId());
                airportExpressIncreaseStrategyReq.setAirportExpressId(productId);
                airportExpressIncreaseStrategyReq.setIncreaseStrategyName(productIncreaseStrategyReq.getName());

                //策略时间
                List<ProductDateReq> dateReqList = productIncreaseStrategyReq.getDateReqList();
                List<AirportExpressIncreaseStrategyDateReq> airportExpressIncreaseStrategyDateReqList = new ArrayList<>();
                AirportExpressIncreaseStrategyDateReq airportExpressIncreaseStrategyDateReq = null;
                for (ProductDateReq dateReq : dateReqList) {
                    airportExpressIncreaseStrategyDateReq = new AirportExpressIncreaseStrategyDateReq();
                    airportExpressIncreaseStrategyDateReq.setIncreaseStrategyId(productIncreaseStrategyReq.getIncreaseStrategyId());
                    airportExpressIncreaseStrategyDateReq.setDateBegin(dateReq.getBeginDate());
                    airportExpressIncreaseStrategyDateReq.setDateEnd(dateReq.getEndDate());
                    airportExpressIncreaseStrategyDateReqList.add(airportExpressIncreaseStrategyDateReq);
                }
                airportExpressIncreaseStrategyReq.setAirportExpressIncreaseStrategyDateList(airportExpressIncreaseStrategyDateReqList);
                //渠道加幅规则
                ProductChannelSaleReq channelSaleReq = productIncreaseStrategyReq.getChannelSaleReq();
                //渠道加幅规则-线下自营渠道
                ProductChannelOfflineSelfReq offlineSelfReq = channelSaleReq.getOfflineSelfReq();
                if (offlineSelfReq != null) {
                    airportExpressIncreaseStrategyReq.setSelfSalePermissionType(offlineSelfReq.getVisableType());
                    if (airportExpressIncreaseStrategyReq.getSelfSalePermissionType() != null) {
                        if (airportExpressIncreaseStrategyReq.getSelfSalePermissionType() == 2) {
                            AirportExpressIncreaseStrategyRuleReq airportExpressIncreaseStrategySelfRule = EntityUtil.copy(offlineSelfReq, AirportExpressIncreaseStrategyRuleReq.class);
//                        AirportExpressIncreaseStrategyRuleReq airportExpressIncreaseStrategySelfRule = new AirportExpressIncreaseStrategyRuleReq();
                            //是否限购转换（门票景点 0：不限购  1：限购） =》  （业务 1：不限购 2 ：限购）
//                        convertorLimitNum(ProductOfflineChannelReq, airportExpressIncreaseStrategySelfRule);
                            airportExpressIncreaseStrategySelfRule.setIncreaseStrategyId(productIncreaseStrategyReq.getIncreaseStrategyId());
                            airportExpressIncreaseStrategySelfRule.setSaleableType(offlineSelfReq.getIsLimit());
                            airportExpressIncreaseStrategySelfRule.setSaleableNumber(offlineSelfReq.getLimitNum());

                            airportExpressIncreaseStrategyReq.setAirportExpressIncreaseStrategySelfRule(airportExpressIncreaseStrategySelfRule);
                        } else if (airportExpressIncreaseStrategyReq.getSelfSalePermissionType() == 3) {
                            List<AirportExpressChannelOfflineSelfCustomReq> airportExpressChannelOfflineSelfCustomReqList = new ArrayList<>();

                            List<ProductChannelOfflineSelfSubReq> offlineSelfSubReqList = offlineSelfReq.getOfflineSelfSubReqList();
                            for (ProductChannelOfflineSelfSubReq productChannelOfflineSelfSubReq : offlineSelfSubReqList) {
                                AirportExpressChannelOfflineSelfCustomReq airportExpressChannelOfflineSelfCustomReq = new AirportExpressChannelOfflineSelfCustomReq();
                                airportExpressChannelOfflineSelfCustomReq.setName(productChannelOfflineSelfSubReq.getName());
                                airportExpressChannelOfflineSelfCustomReq.setCheckType(productChannelOfflineSelfSubReq.getCheckType());
                                airportExpressChannelOfflineSelfCustomReq.setRelationId(productChannelOfflineSelfSubReq.getRelationId());
                                airportExpressChannelOfflineSelfCustomReq.setIncreaseStrategyId(productIncreaseStrategyReq.getIncreaseStrategyId());
                                // rule
                                AirportExpressIncreaseStrategyRuleReq airportExpressIncreaseStrategySelfRule = EntityUtil.copy(productChannelOfflineSelfSubReq, AirportExpressIncreaseStrategyRuleReq.class);
                                airportExpressChannelOfflineSelfCustomReq.setId(productChannelOfflineSelfSubReq.getOfflineSelfSubId());

                                airportExpressIncreaseStrategySelfRule.setId(productChannelOfflineSelfSubReq.getRuleId());
                                airportExpressIncreaseStrategySelfRule.setSaleableType(productChannelOfflineSelfSubReq.getIsLimit());
                                airportExpressIncreaseStrategySelfRule.setSaleableNumber(productChannelOfflineSelfSubReq.getLimitNum());
                                airportExpressIncreaseStrategySelfRule.setIncreaseStrategyId(productIncreaseStrategyReq.getIncreaseStrategyId());

                                airportExpressChannelOfflineSelfCustomReq.setAirportExpressIncreaseStrategyRule(airportExpressIncreaseStrategySelfRule);
                                airportExpressChannelOfflineSelfCustomReqList.add(airportExpressChannelOfflineSelfCustomReq);
                            }
                            airportExpressIncreaseStrategyReq.setAirportExpressChannelOfflineSelfCustomList(airportExpressChannelOfflineSelfCustomReqList);
                        }
                    }
                }
                //渠道加幅规则-线下代理商渠道
                ProductChannelOfflineAgentReq offlineAgentReq = channelSaleReq.getOfflineAgentReq();
                if (offlineAgentReq != null) {
                    airportExpressIncreaseStrategyReq.setAgentSalePermissionType(offlineAgentReq.getVisableType());
                    if (airportExpressIncreaseStrategyReq.getAgentSalePermissionType() != null) {
                        if (airportExpressIncreaseStrategyReq.getAgentSalePermissionType() == 2) {
                            AirportExpressIncreaseStrategyRuleReq airportExpressIncreaseStrategySelfRule = EntityUtil.copy(offlineAgentReq, AirportExpressIncreaseStrategyRuleReq.class);
//                        AirportExpressIncreaseStrategyRuleReq airportExpressIncreaseStrategySelfRule = new AirportExpressIncreaseStrategyRuleReq();
                            //是否限购转换（门票景点 0：不限购  1：限购） =》  （业务 1：不限购 2 ：限购）
                            //convertorLimitNum(ProductAgentReq, airportExpressIncreaseStrategySelfRule);
                            airportExpressIncreaseStrategySelfRule.setSaleableType(offlineAgentReq.getIsLimit());
                            airportExpressIncreaseStrategySelfRule.setSaleableNumber(offlineAgentReq.getLimitNum());
                            airportExpressIncreaseStrategySelfRule.setIncreaseStrategyId(productIncreaseStrategyReq.getIncreaseStrategyId());

                            airportExpressIncreaseStrategyReq.setAirportExpressIncreaseStrategyAgentRule(airportExpressIncreaseStrategySelfRule);
                        } else if (airportExpressIncreaseStrategyReq.getAgentSalePermissionType() == 3) {
                            List<AirportExpressChannelOfflineAgentCustomReq> airportExpressChannelOfflineAgentCustomReqs = new ArrayList<>();

                            List<ProductChannelOfflineAgentSubReq> offlineAgentSubReqList = offlineAgentReq.getOfflineAgentSubReqList();
                            for (ProductChannelOfflineAgentSubReq offlineAgentSubReq : offlineAgentSubReqList) {
                                AirportExpressChannelOfflineAgentCustomReq airportExpressChannelOfflineAgentCustomReq = new AirportExpressChannelOfflineAgentCustomReq();
                                airportExpressChannelOfflineAgentCustomReq.setAgentId(offlineAgentSubReq.getAgentId());
                                airportExpressChannelOfflineAgentCustomReq.setAgentName(offlineAgentSubReq.getAgentName());
                                airportExpressChannelOfflineAgentCustomReq.setIncreaseStrategyId(productIncreaseStrategyReq.getIncreaseStrategyId());
                                //
                                AirportExpressIncreaseStrategyRuleReq airportExpressIncreaseStrategySelfRule = EntityUtil.copy(offlineAgentSubReq, AirportExpressIncreaseStrategyRuleReq.class);
                                airportExpressChannelOfflineAgentCustomReq.setId(offlineAgentSubReq.getOfflineAgentSubId());

                                airportExpressIncreaseStrategySelfRule.setId(offlineAgentSubReq.getRuleId());
                                airportExpressIncreaseStrategySelfRule.setSaleableType(offlineAgentSubReq.getIsLimit());
                                airportExpressIncreaseStrategySelfRule.setSaleableNumber(offlineAgentSubReq.getLimitNum());
                                airportExpressIncreaseStrategySelfRule.setIncreaseStrategyId(productIncreaseStrategyReq.getIncreaseStrategyId());
                                // 数值百分比转换（门票景点  0：加数值  1：百分比） =》（业务 1：加数值 2：百分比）
                                //成人单程

                                airportExpressChannelOfflineAgentCustomReq.setAirportExpressIncreaseStrategyRule(airportExpressIncreaseStrategySelfRule);
                                airportExpressChannelOfflineAgentCustomReqs.add(airportExpressChannelOfflineAgentCustomReq);
                            }
                            airportExpressIncreaseStrategyReq.setAirportExpressChannelOfflineAgentCustomList(airportExpressChannelOfflineAgentCustomReqs);
                        }
                    }
                }
                //渠道加幅规则-线上自营渠道官方平台
                List<ProductChannelOnlineSelfReq> onlineSelfReqList = channelSaleReq.getOnlineSelfReqList();
                List<AirportExpressChannelOnlineSelfPlatformReq> airportExpressChannelOnlineSelfPlatformReqList = new ArrayList<>();
                airportExpressIncreaseStrategyReq.setAirportExpressChannelOnlineSelfPlatformList(airportExpressChannelOnlineSelfPlatformReqList);
                if (CollectionUtils.isNotEmpty(onlineSelfReqList)) {
                    for (ProductChannelOnlineSelfReq productChannelOnlineSelfReq : onlineSelfReqList) {
                        AirportExpressChannelOnlineSelfPlatformReq airportExpressChannelOnlineSelfPlatformReq = new AirportExpressChannelOnlineSelfPlatformReq();
                        //渠道信息
                        airportExpressChannelOnlineSelfPlatformReq.setChannelId(productChannelOnlineSelfReq.getChannelId());
                        airportExpressChannelOnlineSelfPlatformReq.setChannelName(productChannelOnlineSelfReq.getChannelName());
                        airportExpressChannelOnlineSelfPlatformReq.setIncreaseStrategyId(productIncreaseStrategyReq.getIncreaseStrategyId());
                        //
                        AirportExpressIncreaseStrategyRuleReq airportExpressIncreaseStrategyRule = EntityUtil.copy(productChannelOnlineSelfReq, AirportExpressIncreaseStrategyRuleReq.class);
                        airportExpressChannelOnlineSelfPlatformReq.setId(productChannelOnlineSelfReq.getOnlineSelfId());

                        airportExpressIncreaseStrategyRule.setId(productChannelOnlineSelfReq.getRuleId());
                        airportExpressIncreaseStrategyRule.setSaleableType(productChannelOnlineSelfReq.getIsLimit());
                        airportExpressIncreaseStrategyRule.setSaleableNumber(productChannelOnlineSelfReq.getLimitNum());
                        airportExpressIncreaseStrategyRule.setIncreaseStrategyId(productIncreaseStrategyReq.getIncreaseStrategyId());
                        // 数值百分比转换（门票景点  0：加数值  1：百分比） =》（业务 1：加数值 2：百分比）
                        //成人单程加幅价格

                        airportExpressChannelOnlineSelfPlatformReq.setAirportExpressIncreaseStrategyRule(airportExpressIncreaseStrategyRule);
                        airportExpressChannelOnlineSelfPlatformReqList.add(airportExpressChannelOnlineSelfPlatformReq);
                    }
                }
                //渠道加幅规则-线上第三方平台
                List<ProductChannelOnlineThirdReq> onlineThirdReqList = channelSaleReq.getOnlineThirdReqList();
                List<AirportExpressChannelOnlineThirdPlatformReq> airportExpressChannelOnlineThirdPlatformList = new ArrayList<>();
                airportExpressIncreaseStrategyReq.setAirportExpressChannelOnlineThirdPlatformList(airportExpressChannelOnlineThirdPlatformList);
                if (CollectionUtils.isNotEmpty(onlineThirdReqList)) {
                    for (ProductChannelOnlineThirdReq productChannelOnlineThirdReq : onlineThirdReqList) {
                        AirportExpressChannelOnlineThirdPlatformReq airportExpressChannelOnlineThirdPlatformReq = new AirportExpressChannelOnlineThirdPlatformReq();
                        //渠道信息
                        airportExpressChannelOnlineThirdPlatformReq.setPlatformId(productChannelOnlineThirdReq.getPlatformId());
                        airportExpressChannelOnlineThirdPlatformReq.setPlatformName(productChannelOnlineThirdReq.getPlatformName());
                        airportExpressChannelOnlineThirdPlatformReq.setIncreaseStrategyId(productIncreaseStrategyReq.getIncreaseStrategyId());
                        //
                        AirportExpressIncreaseStrategyRuleReq airportExpressIncreaseStrategyRule = EntityUtil.copy(productChannelOnlineThirdReq, AirportExpressIncreaseStrategyRuleReq.class);
                        airportExpressChannelOnlineThirdPlatformReq.setId(productChannelOnlineThirdReq.getOnlineThirdId());

                        airportExpressIncreaseStrategyRule.setId(productChannelOnlineThirdReq.getRuleId());
                        airportExpressIncreaseStrategyRule.setSaleableType(productChannelOnlineThirdReq.getIsLimit());
                        airportExpressIncreaseStrategyRule.setSaleableNumber(productChannelOnlineThirdReq.getLimitNum());
                        airportExpressIncreaseStrategyRule.setIncreaseStrategyId(productIncreaseStrategyReq.getIncreaseStrategyId());
                        // 数值百分比转换（门票景点  0：加数值  1：百分比） =》（业务 1：加数值 2：百分比）
                        //成人单程加幅价格

                        airportExpressChannelOnlineThirdPlatformReq.setAirportExpressIncreaseStrategyRule(airportExpressIncreaseStrategyRule);
                        airportExpressChannelOnlineThirdPlatformList.add(airportExpressChannelOnlineThirdPlatformReq);
                    }
                }
            }
        }
        return airportExpressIncreaseStrategySaveBatchReq;
    }

    /**
     * 机场快线转前端模板
     *
     * @param airportExpressIncreaseStrategyDTOList
     * @return
     */
    public static List<ProductIncreaseStrategyDTO> airportExpressToStrategyTemp(List<AirportExpressIncreaseStrategyDTO> airportExpressIncreaseStrategyDTOList) {
        List<ProductIncreaseStrategyDTO> increaseStrategyDTOS = new ArrayList<>();
        for (AirportExpressIncreaseStrategyDTO airportExpressIncreaseStrategyDTO : airportExpressIncreaseStrategyDTOList) {
            ProductIncreaseStrategyDTO batchSaleStrategyDTO = new ProductIncreaseStrategyDTO();
            increaseStrategyDTOS.add(batchSaleStrategyDTO);

            batchSaleStrategyDTO.setIncreaseStrategyId(airportExpressIncreaseStrategyDTO.getId());
            batchSaleStrategyDTO.setName(airportExpressIncreaseStrategyDTO.getIncreaseStrategyName());
            // 转换生效时间
            List<ProductDateDTO> productDateDTOList = new ArrayList<>();
            batchSaleStrategyDTO.setDateDTOList(productDateDTOList);
            for (AirportExpressIncreaseStrategyDateDTO airportExpressIncreaseStrategyDateDTO : airportExpressIncreaseStrategyDTO.getAirportExpressIncreaseStrategyDateList()) {
                ProductDateDTO productDateDTO = new ProductDateDTO();
                productDateDTOList.add(productDateDTO);
                productDateDTO.setBeginDate(airportExpressIncreaseStrategyDateDTO.getDateBegin());
                productDateDTO.setEndDate(airportExpressIncreaseStrategyDateDTO.getDateEnd());
            }
            // 转换加幅策略
            ProductChannelSaleDTO channelSaleDTO = new ProductChannelSaleDTO();
            batchSaleStrategyDTO.setChannelSaleDTO(channelSaleDTO);
            // 转换加幅策略-线下自营渠道
            Integer selfSalePermissionType = airportExpressIncreaseStrategyDTO.getSelfSalePermissionType();
            if (selfSalePermissionType != null) {
                AirportExpressIncreaseStrategyRuleDTO airportExpressIncreaseStrategySelfRule = airportExpressIncreaseStrategyDTO.getAirportExpressIncreaseStrategySelfRule();
                ProductChannelOfflineSelfDTO productChannelOfflineSelfDTO;
                if (airportExpressIncreaseStrategySelfRule != null) {
                    productChannelOfflineSelfDTO = EntityUtil.copy(airportExpressIncreaseStrategySelfRule, ProductChannelOfflineSelfDTO.class);
                    productChannelOfflineSelfDTO.setOfflineSelfId(airportExpressIncreaseStrategySelfRule.getId());
                } else {
                    productChannelOfflineSelfDTO = new ProductChannelOfflineSelfDTO();
                }
                channelSaleDTO.setOfflineSelfDTO(productChannelOfflineSelfDTO);

                productChannelOfflineSelfDTO.setVisableType(selfSalePermissionType);
                // 线下自营-渠道
                if (selfSalePermissionType == 2) {
                    productChannelOfflineSelfDTO.setIsLimit(airportExpressIncreaseStrategySelfRule.getSaleableType());
                    productChannelOfflineSelfDTO.setLimitNum(airportExpressIncreaseStrategySelfRule.getSaleableNumber());
                } else if (selfSalePermissionType == 3) {
                    List<ProductChannelOfflineSelfSubDTO> productChannelOfflineSelfCustomDTOS = new ArrayList<>();
                    productChannelOfflineSelfDTO.setOfflineSelfSubDTOList(productChannelOfflineSelfCustomDTOS);

                    List<AirportExpressChannelOfflineSelfCustomDTO> airportExpressChannelOfflineSelfCustomList = airportExpressIncreaseStrategyDTO.getAirportExpressChannelOfflineSelfCustomList();
                    for (AirportExpressChannelOfflineSelfCustomDTO airportExpressChannelOfflineSelfCustomDTO : airportExpressChannelOfflineSelfCustomList) {
                        AirportExpressIncreaseStrategyRuleDTO increaseStrategyRule = airportExpressChannelOfflineSelfCustomDTO.getAirportExpressIncreaseStrategyRule();
                        ProductChannelOfflineSelfSubDTO productChannelOfflineSelfSubDTO = EntityUtil.copy(increaseStrategyRule, ProductChannelOfflineSelfSubDTO.class);
                        productChannelOfflineSelfCustomDTOS.add(productChannelOfflineSelfSubDTO);

                        if (null != productChannelOfflineSelfSubDTO) {
                            productChannelOfflineSelfSubDTO.setOfflineSelfSubId(airportExpressChannelOfflineSelfCustomDTO.getId());
                            productChannelOfflineSelfSubDTO.setRuleId(increaseStrategyRule.getId());
                            productChannelOfflineSelfSubDTO.setCheckType(airportExpressChannelOfflineSelfCustomDTO.getCheckType());
                            productChannelOfflineSelfSubDTO.setRelationId(airportExpressChannelOfflineSelfCustomDTO.getRelationId());
                            productChannelOfflineSelfSubDTO.setName(airportExpressChannelOfflineSelfCustomDTO.getName());
                            productChannelOfflineSelfSubDTO.setIsLimit(increaseStrategyRule.getSaleableType());
                            productChannelOfflineSelfSubDTO.setLimitNum(increaseStrategyRule.getSaleableNumber());
                        }
                    }
                }
            }
            // 转换加幅策略-线下代理渠道
            Integer agentSalePermissionType = airportExpressIncreaseStrategyDTO.getAgentSalePermissionType();
            if (agentSalePermissionType != null) {
                AirportExpressIncreaseStrategyRuleDTO airportExpressIncreaseStrategyAgentRule = airportExpressIncreaseStrategyDTO.getAirportExpressIncreaseStrategyAgentRule();
                ProductChannelOfflineAgentDTO productAgentDTO;
                if (airportExpressIncreaseStrategyAgentRule != null) {
                    productAgentDTO = EntityUtil.copy(airportExpressIncreaseStrategyAgentRule, ProductChannelOfflineAgentDTO.class);
                    productAgentDTO.setOfflineAgentId(airportExpressIncreaseStrategyAgentRule.getId());
                } else {
                    productAgentDTO = new ProductChannelOfflineAgentDTO();
                }
                channelSaleDTO.setOfflineAgentDTO(productAgentDTO);
//                        AirportExpressIncreaseStrategyRuleReq airportExpressIncreaseStrategySelfRule = new AirportExpressIncreaseStrategyRuleReq();
                //是否限购转换（门票景点 0：不限购  1：限购） =》  （业务 1：不限购 2 ：限购）
//                        convertorLimitNum(productOfflineChannelReq, airportExpressIncreaseStrategySelfRule);
                productAgentDTO.setVisableType(agentSalePermissionType);

                // 线下自营-渠道
                if (agentSalePermissionType == 2) {
                    productAgentDTO.setIsLimit(airportExpressIncreaseStrategyAgentRule.getSaleableType());
                    productAgentDTO.setLimitNum(airportExpressIncreaseStrategyAgentRule.getSaleableNumber());
                } else if (agentSalePermissionType == 3) {
                    List<ProductChannelOfflineAgentSubDTO> productChannelOfflineAgentCustomDTOS = new ArrayList<>();
                    productAgentDTO.setOfflineAgentSubDTOList(productChannelOfflineAgentCustomDTOS);

                    List<AirportExpressChannelOfflineAgentCustomDTO> airportExpressChannelOfflineAgentCustomList = airportExpressIncreaseStrategyDTO.getAirportExpressChannelOfflineAgentCustomList();
                    for (AirportExpressChannelOfflineAgentCustomDTO airportExpressChannelOfflineAgentCustomDTO : airportExpressChannelOfflineAgentCustomList) {
                        AirportExpressIncreaseStrategyRuleDTO increaseStrategyRule = airportExpressChannelOfflineAgentCustomDTO.getAirportExpressIncreaseStrategyRule();
                        ProductChannelOfflineAgentSubDTO productChannelOfflineAgentSubDTO = EntityUtil.copy(increaseStrategyRule, ProductChannelOfflineAgentSubDTO.class);
                        productChannelOfflineAgentCustomDTOS.add(productChannelOfflineAgentSubDTO);

                        if (null != productChannelOfflineAgentSubDTO) {
                            productChannelOfflineAgentSubDTO.setOfflineAgentSubId(airportExpressChannelOfflineAgentCustomDTO.getId());
                            productChannelOfflineAgentSubDTO.setRuleId(increaseStrategyRule.getId());
                            productChannelOfflineAgentSubDTO.setAgentId(airportExpressChannelOfflineAgentCustomDTO.getAgentId());
                            productChannelOfflineAgentSubDTO.setAgentName(airportExpressChannelOfflineAgentCustomDTO.getAgentName());
                            productChannelOfflineAgentSubDTO.setIsLimit(increaseStrategyRule.getSaleableType());
                            productChannelOfflineAgentSubDTO.setLimitNum(increaseStrategyRule.getSaleableNumber());
                        }
                    }
                }
            }
            // 转换加幅策略-线上门店渠道
            List<AirportExpressChannelOnlineSelfPlatformDTO> airportExpressChannelOnlineSelfPlatformList = airportExpressIncreaseStrategyDTO.getAirportExpressChannelOnlineSelfPlatformList();
            if (CollectionUtils.isNotEmpty(airportExpressChannelOnlineSelfPlatformList)) {
                List<ProductChannelOnlineSelfDTO> productChannelOnlineSelfPlatformDTOS = new ArrayList<>();
                channelSaleDTO.setOnlineSelfDTOList(productChannelOnlineSelfPlatformDTOS);
                for (AirportExpressChannelOnlineSelfPlatformDTO airportExpressChannelOnlineSelfPlatformDTO : airportExpressChannelOnlineSelfPlatformList) {
                    AirportExpressIncreaseStrategyRuleDTO increaseStrategyRule = airportExpressChannelOnlineSelfPlatformDTO.getAirportExpressIncreaseStrategyRule();
                    ProductChannelOnlineSelfDTO productChannelOnlineSelfDTO = EntityUtil.copy(increaseStrategyRule, ProductChannelOnlineSelfDTO.class);
                    productChannelOnlineSelfPlatformDTOS.add(productChannelOnlineSelfDTO);

                    if (null != productChannelOnlineSelfDTO) {
                        productChannelOnlineSelfDTO.setOnlineSelfId(airportExpressChannelOnlineSelfPlatformDTO.getId());
                        productChannelOnlineSelfDTO.setRuleId(increaseStrategyRule.getId());
                        productChannelOnlineSelfDTO.setChannelId(airportExpressChannelOnlineSelfPlatformDTO.getChannelId());
                        productChannelOnlineSelfDTO.setChannelName(airportExpressChannelOnlineSelfPlatformDTO.getChannelName());
                        productChannelOnlineSelfDTO.setIsLimit(increaseStrategyRule.getSaleableType());
                        productChannelOnlineSelfDTO.setLimitNum(increaseStrategyRule.getSaleableNumber());
                    }
                }
            }

            // 转换加幅策略-线上门店渠道
            List<AirportExpressChannelOnlineThirdPlatformDTO> airportExpressChannelOnlineThirdPlatformList = airportExpressIncreaseStrategyDTO.getAirportExpressChannelOnlineThirdPlatformList();
            if (CollectionUtils.isNotEmpty(airportExpressChannelOnlineThirdPlatformList)) {
                List<ProductChannelOnlineThirdDTO> productChannelOnlineThirdPlatformDTOS = new ArrayList<>();
                channelSaleDTO.setOnlineThirdDTOList(productChannelOnlineThirdPlatformDTOS);
                for (AirportExpressChannelOnlineThirdPlatformDTO airportExpressChannelOnlineThirdPlatformDTO : airportExpressChannelOnlineThirdPlatformList) {
                    AirportExpressIncreaseStrategyRuleDTO increaseStrategyRule = airportExpressChannelOnlineThirdPlatformDTO.getAirportExpressIncreaseStrategyRule();
                    ProductChannelOnlineThirdDTO productChannelOnlineThirdPlatformDTO = EntityUtil.copy(increaseStrategyRule, ProductChannelOnlineThirdDTO.class);
                    productChannelOnlineThirdPlatformDTOS.add(productChannelOnlineThirdPlatformDTO);

                    if (null != productChannelOnlineThirdPlatformDTO) {
                        productChannelOnlineThirdPlatformDTO.setOnlineThirdId(airportExpressChannelOnlineThirdPlatformDTO.getId());
                        productChannelOnlineThirdPlatformDTO.setRuleId(increaseStrategyRule.getId());
                        productChannelOnlineThirdPlatformDTO.setPlatformId(airportExpressChannelOnlineThirdPlatformDTO.getPlatformId());
                        productChannelOnlineThirdPlatformDTO.setPlatformName(airportExpressChannelOnlineThirdPlatformDTO.getPlatformName());
                        productChannelOnlineThirdPlatformDTO.setIsLimit(increaseStrategyRule.getSaleableType());
                        productChannelOnlineThirdPlatformDTO.setLimitNum(increaseStrategyRule.getSaleableNumber());
                    }
                }
            }
        }
        return increaseStrategyDTOS;
    }
}
